# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=libcanberra
pkgver=0.30
pkgrel=8
pkgdesc="Simple audio library for GTK applications"
url="http://0pointer.de/lennart/projects/libcanberra/"
arch="all"
options="!check"  # No test suite.
license="LGPL-2.1-or-later"
depends="sound-theme-freedesktop"
makedepends="
	alsa-lib-dev
	eudev-dev
	gstreamer-dev
	gtk+2.0-dev
	gtk+3.0-dev
	libogg-dev
	libtool
	libvorbis-dev
	pulseaudio-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-gtk2
	$pkgname-gtk3
	$pkgname-alsa
	$pkgname-pulse
	$pkgname-gstreamer
	"
source="https://dev.alpinelinux.org/archive/libcanberra/libcanberra-$pkgver.tar.xz
	fix-build-with-no-lynx-installed.patch
	dont-assume-all-GdkDisplays-are-GdkX11Displays.patch
	"

prepare() {
	default_prepare
	update_config_sub
	update_config_guess
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-oss
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install
}

gtk2() {
	pkgdesc="GTK+2.0 bindings for libcanberra"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/lib/libcanberra-gtk.so.*
	amove usr/lib/gtk-2.0
}

gtk3() {
	pkgdesc="GTK+3.0 bindings for libcanberra"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/canberra-gtk-play
	amove usr/lib/gtk-3.0/*
	amove usr/lib/gnome-settings-daemon-3.0/*
	amove usr/lib/libcanberra-gtk3.so.*
	amove usr/share/gdm/*
	amove usr/share/gnome/*
}

alsa() {
	pkgdesc="ALSA backend for libcanberra"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="$pkgname=$pkgver-r$pkgrel alsa-lib !pulseaudio"

	amove usr/lib/libcanberra-$pkgver/libcanberra-alsa.so
}

pulse() {
	pkgdesc="Pulseaudio backend for libcanberra"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="$pkgname=$pkgver-r$pkgrel pulseaudio"

	amove usr/lib/libcanberra-$pkgver/libcanberra-pulse.so
}

gstreamer() {
	pkgdesc="GStreamer backend for libcanberra"
	depends="$pkgname=$pkgver-r$pkgrel"
	install_if="$pkgname=$pkgver-r$pkgrel gstreamer"

	amove usr/lib/libcanberra-$pkgver/libcanberra-gstreamer.so
}

sha512sums="
f7543582122256826cd01d0f5673e1e58d979941a93906400182305463d6166855cb51f35c56d807a56dc20b7a64f7ce4391368d24990c1b70782a7d0b4429c2  libcanberra-0.30.tar.xz
9ac626967a9d7b76f44ae93218527c62bd7fadd54c6853b9ce69feb104ab3e7a967f458eb15d247447034d4a6c9f625992e9cb14225a12e30ea2126ab275014c  fix-build-with-no-lynx-installed.patch
08bcebdb3af3793fc0760a9d04277b4e4f55156fead8bedb875d86fcafa3e01a8731465ec8eec58cf48b82517ed062739995f3d0f04bfeef5f5446c1f25261b7  dont-assume-all-GdkDisplays-are-GdkX11Displays.patch
"
